﻿using System.Linq;
using NUnit.Framework;
using System;

namespace IntellectShop.Tests
{
	[TestFixture]
	public class MailUtilsTests
	{
		[SetUp]
		protected void SetUp()
		{
		}

		[TestCase("", 0)]
		[TestCase("first@test.ru, second@test.ru, third@test.ru", 3)]
		[TestCase("first@test.ru,second@test.ru,third@test.ru", 3)]
		public void TestGetEmals(string emails, int expectedCount)
		{
			Assert.AreEqual(Common.MailUtils.GetEmals(emails).Count, expectedCount);
		}

		[TestCase("", "", ExpectedException = typeof(InvalidOperationException))]
		[TestCase("first@test.ru, second@test.ru, third@test.ru", "first@test.ru")]
		public void TestGetEmalsGetFirst(string emails, string expected)
		{
			Assert.AreEqual(Common.MailUtils.GetEmals(emails).First(), expected);
		}

		[TestCase("", "", ExpectedException = typeof(InvalidOperationException))]
		[TestCase("first@test.ru, second@test.ru, third@test.ru", "third@test.ru")]
		public void TestGetEmalsGetLast(string emails, string expected)
		{
			Assert.AreEqual(Common.MailUtils.GetEmals(emails).Last(), expected);
		}
	}
}
